package componentManager;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.HashMap;

import stemmer.TestStemmer;



public class Terme {
	private int id;
	private static int RADICAL_SIZE = 7;//on prend les 7 premiers caracteres de chaque mot
	private String radical;//le radical du terme

	public Terme(String terme) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
		this.radical = lemmatise(terme);
	}
	
	public static String lemmatise(String terme) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
//		return TestStemmer.stem("french", terme);
		String result = new String(terme);
		if(terme.length()>RADICAL_SIZE){
			result = result.substring(0, RADICAL_SIZE);
		}
		return norm(result);
	}
	
	/**
	 * 
	 * @param s
	 * @return chaîne en minuscules et sans accents et sans espaces avant et apres le mot saisi
	 */
	public static String norm (String s) {
		return Normalizer.normalize(s.toLowerCase().replaceAll("_", " ").trim(), Normalizer.Form.NFD).replaceAll("[\u0300-\u036F]", "");
	}
	
	
	
	public String toString(){
		return radical;
	}

	public String getRadical() {
		return radical;
	}

	public void setRadical(String radical) {
		this.radical = radical;
	}


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	
	
	
	
	
	
}
